using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace IDSDemo.IdentityServerHost
{
    public class Startup
    {
      
        public void ConfigureServices(IServiceCollection services)
        {
            //add mvc
            services.AddMvc();


            var builder = services.AddIdentityServer();
            builder.AddDeveloperSigningCredential();
            //builder.AddSigningCredential();
            builder.AddInMemoryApiScopes(Config.ApiScopes);
            builder.AddInMemoryClients(Config.Clients);
            builder.AddTestUsers(Config.Users);
            builder.AddInMemoryIdentityResources(Config.IdentityResources);

        }

        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseStaticFiles();

            app.UseRouting();

            app.UseIdentityServer();

            app.UseAuthorization();

            app.UseEndpoints(builder =>
            {
                builder.MapDefaultControllerRoute();
            });


        }
    }
}
